/**
 * @author nttdocomo
 */
define(function(require) {
	require("./abstractHelper");
	aries.klass("aries.dom.Helper", aries.dom.AbstractHelper.extend({
		/**
		 * @property {Boolean} useDom
		 * True to force the use of DOM instead of html fragments.
		 */
		useDom : false,
		createDom : function(config) {
			var $dom = $('<' + (config.tag || "div") + '>');
			if (config.cls)
				$dom.addClass(config.cls);
			if (config.attributes)
				$dom.attr(config.attributes);
			return $dom;
		},
		doInsert : function(el, o, returnElement, pos, sibling, append) {

			el = el || $("#" + el);

			var newNode;

			if (this.useDom) {
				newNode = this.createDom(o, null);

				if (append) {
					el.appendChild(newNode);
				} else {
					(sibling == 'firstChild' ? el : el.parentNode).insertBefore(newNode, el[sibling] || el);
				}

			} else {
				newNode = this.insertHtml(pos, el, this.markup(o));
			}
			return returnElement ? Ext.get(newNode, true) : newNode;
		}
	}));
	aries.DomHelper = new aries.dom.Helper;
})
